﻿using System.Collections;
using ThunderboltIocFrame.Interface;

namespace ThunderboltIocFrame.Implement;

public class ServiceCollection : IServiceCollection
{
    private readonly Dictionary<string, ServiceDescriptor> _descriptors = new Dictionary<string, ServiceDescriptor>();

    public ServiceDescriptor this[string index]
    {
        get => _descriptors.TryGetValue(index, out ServiceDescriptor service) ? service : default;
        set => _descriptors[index] = value;
    }

    public int Count => _descriptors.Count;

    public bool IsReadOnly => throw new NotImplementedException();

    public void Add(ServiceDescriptor item)
    {
        _descriptors.Add(item.ImplementType.Name, item);
    }

    public void Clear()
    {
        _descriptors.Clear();
    }

    public bool Contains(ServiceDescriptor item)
    {
        return _descriptors.ContainsValue(item);
    }

    public void CopyTo(ServiceDescriptor[] array, int arrayIndex)
    {
        throw new NotImplementedException();
    }

    public IEnumerator<ServiceDescriptor> GetEnumerator()
    {
        throw new NotImplementedException();
    }

    public bool Remove(ServiceDescriptor item)
    {
        throw new NotImplementedException();
    }

    IEnumerator IEnumerable.GetEnumerator()
    {
        throw new NotImplementedException();
    }
}